#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <unordered_set>

using namespace std;

bool wordBreak(string s, vector<string>& wordDict) {
    s = ' ' + s;
    int n = s.size();
    vector<bool> dp(n + 1, false);
    dp[0] = true;

    unordered_set<string> hash;
    for (auto& s : wordDict)
        hash.insert(s);

    for (int i = 1; i <= n; ++i)
    {
        for (int j = i; j >= 1; --j)
        {
            if (dp[j - 1] && hash.count(s.substr(j, i - j + 1)))
            {
                dp[i] = true;
                break;
            }
        }
    }

    return dp[n];
}

int main()
{

	return 0;
}